/*
 * ftlUtil.c
 *
 *  Created on: 2013-11-6
 *      Author: jzheng
 */

#include "types.h"
#include "util.h"


#define here()  (printk( "%s %d \r\n", __FUNCTION__, __LINE__))

#define debug_msg(fmt,...) printf("%s[%d]:"fmt,__FILE__,__LINE__, ##__VA_ARGS__)
#define printk(fmt, arg...) printf(fmt, ##arg)


void disp_pkt(volatile u8 *ptr, u32 len)
{
    u32 i;
    for(i = 0; i < len; i++)
    {
        if(i % 16 == 0)
            printk("\r\n");

        printk("%02x ", ptr[i]);
    }

    printk("\r\n");
}

void disp_pkt_32(volatile u32 *ptr, u32 len)
{
    u32 i;
    for(i = 0; i < len; i++)
    {
        if(i % 16 == 0)
            printk("\r\n");

        printk("%08x ", ptr[i]);
    }

    printk("\r\n");
}


void *memset32(void *s, unsigned int c, unsigned int count)
{
    unsigned int *xs = (unsigned int *)s;

    while (count--)
        *xs++ = c;

    return s;
}

int checkAllff(unsigned int * buf, unsigned int len)
{
    unsigned int i;

    for (i = 0 ; i < len; i++)
    {
        if (buf[i] != 0xffffffff)
        {
           return FALSE;
        }
    }
    return TRUE;
}


#ifdef OPTION_DEBUG
int nb_memcmp(void *dest, const void *src, unsigned int count)
{
    unsigned char *pc1 = (unsigned char *)dest;
    unsigned char *pc2 = (unsigned char *)src;
    unsigned int i = 0;

    for (; i< count; i++)
    {
        if (*pc1 != *pc2)
            break;
        pc1++; pc2++;
    }

    return (count - i);
}
#endif


